<script type="text/javascript">
	$(document).ready(function(){
		$("input,select,textarea").not("[type=submit]").jqBootstrapValidation({
			submitSuccess: function ($form, event) { 
				event.preventDefault();

				$.ajax({
					type: "POST",
					url: "process_salary.php",
					data: $('#frm_edit_salary').serialize(),
					cach: false,
					error: function() {
						alert("ERROR !!!!");
					},
					success: function(data){
						//alert("dlg_edit" + data);
						//$('.close-dialog').trigger('click');
						window.location.href="index.php?pages=frm_init&submit=s&" + data;
					}
				});

			}
		});
	});
</script>

<?php
	require_once("includes/connect.php");
	require_once("includes/function.php");

  //echo $id, $month_year, $panngan2, $panngan3, $ex1_id, $ex2_id, $ex3_id;
	$id = $_REQUEST["id"];
	
	$month_year = $_REQUEST["month_year"];

	$panngan2 = $_REQUEST["panngan2"];
	$panngan3 = $_REQUEST["panngan3"];

	$salary = $_REQUEST["salary"];

	$budget_year = $_REQUEST["budget_year"];

	$sql = "SELECT * FROM tbl_init
			WHERE card_id = '$id'
			AND panngan2_id = '$panngan2'
			AND panngan3_id = '$panngan3'
			AND month_year = '$month_year'
			AND budget_year = '$budget_year'
			";

	$db = new myDBS;
	$db->selectDB("account");
	$results = $db->runSQL($sql);

	$rows = $db->fetch_object($results);

?>

<form id="frm_edit_salary" name="frm_edit_salary" class="form-horizontal" method="post" action="#" novalidate="">
<input type="hidden" name="task" value="<?php echo (!$rows->init_id)? 'new':'edit'; ?>">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="hidden" name="month_year" value="<?php echo $month_year; ?>">
<input type="hidden" name="panngan2" value="<?php echo $panngan2; ?>">
<input type="hidden" name="panngan3" value="<?php echo $panngan3; ?>">

<input type="hidden" name="salary" value="<?php echo $salary; ?>">
<input type="hidden" name="total1" value="0.00">
<input type="hidden" name="total2" value="0.00">

<input type="hidden" name="budget_year" value="<?php echo $budget_year; ?>">
<div class="panel panel-success">
<div class="panel-heading">ส่วนที่เพิ่ม</div>
<div class="panel-body">
	
	<div class="control-group">
		<label class="control-label">เงินประจำตำแหน่ง</label>
		<div class="controls ">
			<input type="text" id="emoluments" name="emoluments" class="input-large"  value="<?php echo (isset($rows->emoluments))? $rows->emoluments:"0.00"; ?>" required />
		</div>
	</div>

	<div class="control-group">
		<label class="control-label">เงินตกเบิก</label>
		<div class="controls ">
			<input type="text" id="tok_beuk" name="tok_beuk" class="input-large"  value="<?php echo (isset($rows->tok_beuk))? $rows->tok_beuk:"0.00"; ?>" required />
		</div>
	</div>
	

	<div class="control-group">
		<label class="control-label">ค่ารักษาพยาบาล</label>
		<div class="controls ">
			<input type="text" id="medical_fee" name="medical_fee" class="input-large"  value="<?php echo (isset($rows->medical_fee))? $rows->medical_fee:"0.00"; ?>" required />
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">การศึกษาบุตร</label>
		<div class="controls ">
			<input type="text" id="education" name="education" class="input-large"  value="<?php echo (isset($rows->education))? $rows->education:"0.00"; ?>" required />
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">เงินเพิ่ม</label>
		<div class="controls ">
			<input type="text" id="extra" name="extra" class="input-large"  value="<?php echo (isset($rows->extra))? $rows->extra:"0.00"; ?>" required />
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">ค่าเช่าบ้าน</label>
		<div class="controls ">
			<input type="text" id="rent_home" name="rent_home" class="input-large"  value="<?php echo (isset($rows->rent_home))? $rows->rent_home:"0.00"; ?>" required />
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">เงินได้อื่นๆ</label>
		<div class="controls ">
			<input type="text" id="other1" name="other1" class="input-large"  value="<?php echo (isset($rows->other1))? $rows->other1:"0.00"; ?>" required />
		</div>
	</div>
</div>
</div>
</div>
<div class="panel panel-danger hide">
<div class="panel-heading">ส่วนที่หัก</div>
<div class="panel-body">
	<div class="control-group">
		<label class="control-label">ภาษี</label>
		<div class="controls ">
			<input type="text" id="tax" name="tax" class="input-large"  value="<?php echo (isset($rows->tax))? $rows->tax:"0.00"; ?>" required />
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">ก.ฌ.</label>
		<div class="controls ">
			<input type="text" id="cremation1" name="cremation1" class="input-large"  value="<?php echo (isset($rows->cremation1))? $rows->cremation1:"0.00"; ?>" required />
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">สวัสดิการ</label>
		<div class="controls ">
			<input type="text" id="welfare" name="welfare" class="input-large"  value="<?php echo (isset($rows->welfare))? $rows->welfare:"0.00"; ?>" required />
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">สหกรณ์</label>
		<div class="controls ">
			<input type="text" id="cooperative" name="cooperative" class="input-large"  value="<?php echo (isset($rows->cooperative))? $rows->cooperative:"0.00"; ?>" required />
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">กู้เทศบาล</label>
		<div class="controls ">
			<input type="text" id="loan" name="loan" class="input-large"  value="<?php echo (isset($rows->loan))? $rows->loan:"0.00"; ?>" required />
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">ธอ/บงคำ</label>
		<div class="controls ">
			<input type="text" id="bongkum" name="bongkum" class="input-large"  value="<?php echo (isset($rows->bongkum))? $rows->bongkum:"0.00"; ?>" required />
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">ธอส</label>
		<div class="controls ">
			<input type="text" id="ghb" name="ghb" class="input-large"  value="<?php echo (isset($rows->ghb))? $rows->ghb:"0.00"; ?>" required />
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">AIA</label>
		<div class="controls ">
			<input type="text" id="aia" name="aia" class="input-large"  value="<?php echo (isset($rows->aia))? $rows->aia:"0.00"; ?>" required />
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">ก.ฌ. เทศบาล</label>
		<div class="controls ">
			<input type="text" id="cremation2" name="cremation2" class="input-large"  value="<?php echo (isset($rows->cremation2))? $rows->cremation2:"0.00"; ?>" required />
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">อื่นๆ</label>
		<div class="controls ">
			<input type="text" id="other2" name="other2" class="input-large"  value="<?php echo (isset($rows->other2))? $rows->other2:"0.00"; ?>" required />
		</div>
	</div>
</div>
</div>
</div>
<div class="form-actions">
	<input type="submit" class="btn btn-primary" id="save_menus" value="บันทึกการเปลี่ยนแปลง">
	<!--<button class="btn close"><i class="icon-remove"></i> ยกเลิก</button>-->
	<a id="x" href="#" class="btn close-dialog"><i class="icon-remove"></i> ยกเลิก</a>

</div>
</form>

